//
// C++ Implementation: diagramline
//
// Description: 
//
//
// Author: Pilitsyn Vasiliy <nexus@ablogic.ru>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//

#include <qpainter.h>
#include "mainwindow.h"



DiagramLine::DiagramLine(int x, int y, int w, int h,QCanvas *canvas)
   : QCanvasLine(canvas)
{

   setPoints(x, y, w, h);
   setPen(green);
   selectMove = FALSE;
   show();

}

DiagramLine::~DiagramLine()
{
   hide();
}

const int Margin = 3;

void DiagramLine::drawShape(QPainter& p)
{
   QCanvasLine::drawShape(p);

 
   
 if (isSelected()) {
      p.setPen(Qt::black);
      p.setBrush(Qt::yellow);
      QPoint startP  =  startPoint() + offset();
      QPoint endP    = endPoint() + offset();
      
      
      p.drawRect( startP.x()  - Margin, startP.y() - Margin, Margin * 2 + 1, Margin * 2 + 1);
      p.drawRect( endP.x()  - Margin, endP.y() - Margin, Margin * 2 + 1, Margin * 2 + 1);
     
 }else{
    ;
//     p.eraseRect;
 }
   
}

void DiagramLine::scale()
{
   //    setSize(w, h);
   update();
}

void DiagramLine::setSelectMove(bool set){
   selectMove = set;
}

void DiagramLine::setViewSettings(const QString &colorLine){
   
   bool ok;
   setPen(QColor(colorLine.toUInt(&ok,10)));

}

